package com.gitee.andy.rpc.entity;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Arrays;

import org.apache.commons.lang3.builder.ToStringBuilder;

public class RpcRequest implements Serializable {
	private static final long serialVersionUID = 2854679678381117130L;

	private long seq;
	private RpcMethodId rpcMethodId;
	private Object[] args;

	public RpcRequest() {
	}

	public RpcRequest(long seq, Method method, Object[] args) {
		this(seq, method.getDeclaringClass().getName(), method.getName(), method.getParameterTypes(), args);
	}

	public RpcRequest(long seq, String serviceName, String methodName, Class<?>[] parameterTypes, Object[] args) {
		super();
		this.seq = seq;
		this.rpcMethodId = new RpcMethodId(serviceName, methodName, parameterTypes);
		this.args = args;
	}

	public long getSeq() {
		return seq;
	}

	public void setSeq(long seq) {
		this.seq = seq;
	}

	public RpcMethodId getRpcMethodId() {
		return rpcMethodId;
	}

	public void setRpcMethodId(RpcMethodId rpcMethodId) {
		this.rpcMethodId = rpcMethodId;
	}

	public Object[] getArgs() {
		return args;
	}

	public void setArgs(Object[] args) {
		this.args = args;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this);
		builder.append("seq", seq);
		builder.append("rpcMethodId", rpcMethodId);
		builder.append("args", Arrays.toString(args));
		return builder.toString();
	}

}
